package com.suns.demo;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class DelayProducer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("delayed_producer_01");
        producer.setNamesrvAddr("localhost:9876");
        producer.start();

        // 创建消息
        Message message = new Message("tp_02", "hello delay msg".getBytes());
        // 设置消息的延迟级别
        message.setDelayTimeLevel(5);

        SendResult result = producer.send(message);
        System.out.println(result);

        producer.shutdown();
    }
}
